package com.wyt.controller.tupianController;


import com.wyt.dao.TorderMapper;
import com.wyt.dao.ToutstorageMapper;
import com.wyt.entity.Toutstorage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ToutstorageController {

    @Autowired
    private ToutstorageMapper toutstorageMapper;
    @Autowired
    private TorderMapper torderMapper;

    @RequestMapping("/statisc/tu6")
    @ResponseBody
    private Map<String,List> findAllPidAndNameCount(){
        Map<String,List> map=new HashMap<>();
        List<Toutstorage> list=toutstorageMapper.findAllouttroageUidPnameAndCount();
        List list1=new ArrayList();
        List list2=new ArrayList();
        for (Toutstorage t:list
        ) {
            String str=t.getPname()+" "+t.getUid();
            list1.add(str);
            list2.add(t.getCountPname());
        }
        map.put("name",list1);
        map.put("value",list2);
        return map;
    }

    @RequestMapping("/static/tu8")
    @ResponseBody
    public HashMap<String,Object>FindUserAndCode() {
        List<Map<String, Object>> FindUserAndCode = torderMapper.FindUserNameAndCode();
        List<Object> value = new ArrayList<>();
        List<Object> name = new ArrayList<>();
        for (Map<String, Object> m : FindUserAndCode) {
            name.add(m.get("name"));
            value.add(m.get("value"));
        }
        HashMap<String, Object> map = new HashMap<>();
        map.put("name", name);
        map.put("value", value);
        return map;
    }
}
